package DianShang_2024.ds_server.indicator

import org.apache.spark.sql.SparkSession

object data_sql {
  def main(args: Array[String]): Unit = {
    //  准备 sparksql的环境
    val spark = SparkSession.builder()
      .appName("查询表格数据")
      .master("local[*]")
      .enableHiveSupport()
      .getOrCreate()

    //  第一题
    spark.sql(
      """
        |select
        |*
        |from dws.user_consumption_day_aggr
        |where year=2022 and month=4 and day=1
        |limit 10
        |""".stripMargin).show
    //  删除分区的语法
    //    spark.sql("alter table dws.user_consumption_day_aggr drop partition(year=2022)")

    //  第二题
    spark.sql(
      """
        |select
        |*
        |from dws.city_consumption_day_aggr
        |where year=2022 and month=3
        |limit 20
        |""".stripMargin).show




    spark.close()
  }

}
